package com.bw.data_summary;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.TableResult;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
//  门禁类型
public class dwd_access_control_entrance {
    public static void main(String[] args) throws Exception {

        //1.获取Stream的执行环境
        StreamExecutionEnvironment senv = StreamExecutionEnvironment.getExecutionEnvironment();
        senv.setParallelism(1);

        //2.创建表的执行环境
        StreamTableEnvironment tEnv = StreamTableEnvironment.create(senv);


        //3.车辆进出事实表
        tEnv.executeSql("CREATE TABLE `bean_entrance_guard_log`(\n" +
                " id STRING,\n" +
                " openMode SMALLINT,\n" +
                " openTime STRING,\n" +
                " ownerId INT,\n" +
                " proc_time as PROCTIME()\n" +
                ") WITH (\n" +
                " 'connector' = 'kafka',\n" +
                " 'topic' = 'entrance_guard_log',\n" +
                " 'properties.bootstrap.servers' = 'node102:9092',\n" +
                " 'properties.group.id' = 'entrance_guard_log',\n" +
                " 'scan.startup.mode' = 'earliest-offset',\n" +
                " 'format' = 'json'\n" +
                ")\n");

        TableResult result = tEnv.executeSql("SELECT * FROM bean_entrance_guard_log");

        //5.打印查询结果
        result.print();

//        // community 小区信息表
//        tEnv.executeSql(
//                "CREATE TABLE `bean_community` (\n"+
//                   " id INT,\n" +
//                   " communityName STRING,\n" +
//                   " district_id INT,\n" +
//                   " city_id INT,\n" +
//                   " communityLocation STRING,\n" +
//                   " remark STRING,\n" +
//                   " PRIMARY KEY (id) NOT ENFORCED\n" +
//                  ") WITH (\n" +
//                " 'connector' = 'doris' \n"+
//                " 'fenodes' = 'node102:8030' \n"+
//                " 'table.identifier' = 'test.student', \n"+
//                " 'username' = 'root', \n"+
//                " 'password' = '123456', \n"+
//                " 'sink.label-prefix' = 'doris_label' \n"+
//                ")\n");
//
//        // district地区信息表
//        tEnv.executeSql("CREATE TABLE `bean_base_district` (\n" +
//                " `id` INT,\n" +
//                " `pid` INT,\n" +
//                " `code` STRING,\n" +
//                " `name` STRING,\n" +
//                " `remark` STRING,\n" +
//                " `create_time` TIMESTAMP,\n" +
//                " `update_time` TIMESTAMP,\n" +
//                " `status` SMALLINT,\n" +
//                " `level` SMALLINT,\n" +
//                " PRIMARY KEY (`id`)  NOT ENFORCED\n" +
//                ") WITH (\n" +
//                " 'connector' = 'jdbc',\n" +
//                " 'url' = 'jdbc:mysql://hadoop1:3306/sca?useUnicode=true&characterEncoding=utf8',\n" +
//                " 'table-name' = 'dim_base_district',\n" +
//                " 'username' = 'hive',\n" +
//                " 'password' = 'hive' \n" +
//                ")\n");







        senv.execute("dwd_access_control_entrance");

    }
}
